<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of accessory
 *
 * @author Administrator
 */
class accessory extends CI_Controller {

    //put your code here
    function __construct() {
        parent::__construct();
    }

    function index() {
        include_once 'loading_alway.php';
        $data['accessories'] = $this->accessory_model->getAllAccessories();
        $c = $this->category_model->getAllAccessoryCategories();
        $arr = array();
        foreach ($c as $row):
            $a = $this->accessory_model->getAccessoryByCategory($row->category_id);
            array_push($arr, $a);
        endforeach;
        $data['arr_accessory'] = $arr;
        $data['site'] = 'site/accessories';
        $this->load->view('template', $data);
    }

    function accessory_by_category() {
        include_once 'loading_alway.php';
        $id = $this->uri->segment(3);


        if ($this->category_model->getAccessoryCategoryByID($id) == null)
            $data['category_name'] = "Không có sản phẩm";
        else
            $data['category_name'] = $this->category_model->getAccessoryCategoryByID($id)->category_name;
        $data['accessories'] = $this->accessory_model->getAccessoryByCategory($id);
        $data['site'] = 'site/accessory-by-category';
        $this->load->view('template', $data);
    }

    function accessory_detail() {

        include_once 'loading_alway.php';
        $id = $this->uri->segment(3);
        $data['site'] = 'site/accessory-detail';
        $data['accessory'] = $this->accessory_model->getAccessoryByID($id);
        $this->load->view('template', $data);
    }

}

?>
